/*
This program combines the initial and updated disclosures 

It cleans up the variable names and labels variable for easy use

The output file is gvc_output.dta

*/



*1.  import disclosed file
import excel "$input\afft_restat_01.xlsx", ///
	sheet("agg_stats") firstrow clear

*2. clean up variable names	
rename MNE mne_status
rename t2 type



order type mne_status firms_drb prof_firms_drb emp_drb emp_man_drb emp_prof_drb emp_manage_drb sales_drb sales_man_drb ///
	exporter_drb rp_exporter_drb exp_value_drb rp_exp_value_drb ///
	importer_drb rp_importer_drb imp_value_drb rp_imp_value_drb ///
	aff_emp_drb man_aff_emp_drb  ///
	aff_sales_drb man_aff_sales_drb 
	
	
foreach vv in firms prof_firms exporter rp_exporter exp_value rp_exp_value ///
	importer rp_importer imp_value rp_imp_value aff_emp man_aff_emp  ///
	aff_sales man_aff_sales emp emp_man emp_prof emp_manage sales sales_man ///
	sh_man_emp sh_man_sales sh_dom_man_emp {
	rename `vv'_drb `vv'
	}
	
label variable firms "Total firms"	
label variable emp "Total emp in firms, from EC or LBD"
label variable type "MAN=Firms with 1+ US manuf plants"	
label variable type "MAN=Firms with 1+ US manuf plants"	
label variable prof_firms "No of firms with 54 emp"
label variable emp_man "Employment at manuf plants"
label variable emp_prof "Employment at 54 estabs"
label variable emp_manage "Employment at 55 estabs"
label variable sales "Sales from the Economic Censuses"
label variable sales_man "Manuf plant sales"
label variable exporter "Total exporters"
label variable rp_exporter "Total firms with related-party exports"
label variable importer "Total importers"
label variable rp_importer "Total firms with related-party imports"
label variable exp_value "Total exports from LFTTD"
label variable imp_value "Total imports from LFFTD"
label variable rp_exp_value "Total related-party exports from LFTTD"
label variable rp_imp_value "Total related-party imports from LFTTD"
label variable aff_emp "Employment at majority-owned foreign affiliates"
label variable man_aff_emp "Employment at majority-owned foreign manuf affiliates"	
label variable aff_sales "Sales by majority-owned foreign affiliates"
label variable man_aff_sales "Sales by majority-owned foreign manuf affiliates"	
label variable sh_man_emp "US manuf emp over total US emp"
label variable sh_man_sales "US manuf sales over total US sales"
label variable sh_dom_man_emp "US manuf emp over US+Foreign Manuf emp"


save $data/gvc_output.dta, replace

